<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");	
	String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<!DOCTYPE HTML>
<html>
  <head>
    <%@include file="../common.jsp"%>
    <title>编辑职业考证</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">  
<!-- 	<link rel="stylesheet" type="text/css" href="resources/css/common.css">  -->
 	<script type="text/javascript" src="resources/js/file/edit_file.js"></script>  
	
	<!--kindEditor -->
    <link rel="stylesheet" href="resources/js/kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="resources/js/kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="resources/js/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="resources/js/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="resources/js/kindeditor/plugins/code/prettify.js"></script> 
	
<!-- 	<script type="text/javascript" src="resources/js/jquery.tagbox.js"></script>  
	<link rel="stylesheet" type="text/css" href="resources/css/jquery.tagbox.css"> -->
	
	
	<!-- 断点上传 -->
	<link rel="stylesheet" href="resources/css/webuploader.css" />
    <link rel="stylesheet" href="resources/css/bootstrap/bootstrap.css" />
	<script src="resources/js/md5.js" type="text/javascript" charset="utf-8"></script>
	<script src="resources/js/webuploader.js" type="text/javascript" charset="utf-8"></script>
 	 <script src="resources/js/fileUpload.js" type="text/javascript" charset="utf-8"></script> 
 	
	<script src="resources/js/tag/jquery.tagsinput.js"></script>
	<link href="resources/js/tag/jquery.tagsinput.css" rel="stylesheet" />	
		
<script>		
	KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content1"]', {
				cssPath : 'resources/js/kindeditor/plugins/code/prettify.css',
				uploadJson : 'resources/js/kindeditor/jsp/upload_json.jsp',
				fileManagerJson : 'resources/js/kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				
				afterBlur: function(){
					this.sync();
				}
			});
			prettyPrint();
		});
		
	var fileId = "${fileId}";
	
	function editCategory(tcId, scId, detailIdList) {
		var $second = $("#form_edit").find("[name=second]"), $top = $("#form_edit").find("[name=top]");
		$detail = $("#form_edit").find("[name=detail]"); 
		$.get("view/video/category/getTopCategory", function(data) {
			$.each(data.data, function(i, obj) {
				if (obj.tcId == tcId) {
					$top.append("<option value='" + obj.tcId + "' selected>"+ obj.tcName + "</option>");
				} 
			});
		}, "json");
		$.ajax({ // 此处用同步处理，避免出现val()比reload早的问题
					url : serverURL + "view/video/category/getSecondaryCategory?"+ "tcId=" + tcId,
					type : "get",
					async : false,
					success : function(data) {
						if (data.code == 0) {
							var html = "";
							$.each(data.data, function(i, k) {
								if (k.scId == scId) {
									html += "<option value='" + k.scId+ "' selected>" + k.scName	+ "</option>";
								} else {
									html += "<option value='" + k.scId + "'>"+ k.scName + "</option>";
								}
							});
							$second.append(html);
						} else if (data.code != -1) {
							alert("一二级分类数据加载失败");
						}
					}
				});

		$.ajax({
			url : serverURL + "view/video/category/getDetailCategory?" + "scId=" + scId+ "&dcTypeId=0",
			type : "get",
			async : false,
			success : function(data) {
				if (data.code == 0) {
					var detail = content = projectMode = "";
					$.each(data.data, function(i, k) {
							if (k.dcId == detailIdList[0]) {
								detail += "<option value='" + k.dcId+ "' selected >" + k.dcName+ "</option>";
							} else {
								detail += "<option value='" + k.dcId + "'>"+ k.dcName + "</option>";
							}
					});
					$detail.append(detail);
				} else if (data.code != -1) {
					alert("三级分类数据加载失败");
				}
			}
		});

		/*--------------修改的一、二、三级二级联动处理----------------*/
		$top.change(function() {
			districtEdit.clearDetail();
			districtEdit.reloadSecond($(this).val());
		});

		$second.change(function() {
			districtEdit.reloadDetail($(this).val());
		});

		var districtEdit = {
			clearSecond : function() {
				$second.find("option[value!=0]").remove();
			},
			clearDetail : function() {
				$detail.find("option[value!=0]").remove();
			},
			reloadSecond : function(tcId) {
				districtEdit.clearSecond();
				if (tcId != 0) {
					$.ajax({ // 此处用同步处理，避免出现val()比reload早的问题
						url : serverURL + "view/video/category/getSecondaryCategory?"+ "tcId=" + tcId,
						type : "get",
						async : false,
						success : function(data) {
							if (data.code == 0) {
								var html = "";
								$.each(data.data,
										function(i, k) {
											if (k.scId == scId) {
												html += "<option value='"+ k.scId+ "' selected>"+ k.scName+ "</option>";
											} else {
												html += "<option value='"+ k.scId + "'>"+ k.scName+ "</option>";
											}
										});
								$second.append(html);
							} else if (data.code != -1) {
								alert("一二级分类数据加载失败");
							}
						}
					});
				}
			},
			reloadDetail : function(scId) {
				districtEdit.clearDetail();
				if (scId != 0) {
					$.ajax({
						url : serverURL + "view/video/category/getDetailCategory?"+ "scId=" + scId + "&dcTypeId=0",
						type : "get",
						async : false,
						success : function(data) {
							if (data.code == 0) {
								$.each(data.data, function(i, k) {
									if (k.dcType == 1 || k.dcType == 4|| k.dcType == 7) {
										$detail.append("<option value='"+ k.dcId + "'>" + k.dcName+ "</option>");
									} else if (k.dcType == 2 || k.dcType == 5|| k.dcType == 8) {
										$content.append("<option value='"+ k.dcId + "'>" + k.dcName+ "</option>");
									} else if (k.dcType == 3 || k.dcType == 6|| k.dcType == 9) {
										$projectMode.append("<option value='"+ k.dcId + "'>" + k.dcName+ "</option>");
									} else if (k.dcType == 0) { // 国外工程资料
										$detail.append("<option value='"+ k.dcId + "'>" + k.dcName+ "</option>");
									}
								});
							} else if (data.code != -1) {
								alert("三级分类数据加载失败");
							}
						}
					});
				}
			}
		};
	}
</script>
</head>
<body>
	<div class="content">
		<ol class="breadcrumb">
			<li><a href="cert.htm">职业考证体系</a></li>
			<li class="active">添加职业考证</li>
		</ol>
		<!-- 添加 -->
		<div class="modal-body" style="margin-left:50px;">
		<div >
			<span id="file_path"></span>
		</div>
			<div id="itemFileName"></div>
			<div style="height:50px;">
				<ul id="theList"></ul>
			</div>
			<div id="uploader">
				<button id="picker" resetValue="0" class="btn btn-primary ">选择文件</button>
			</div>
		</div>

		<div class="modal-content">
			<div class="modal-body">
				<form id="form_edit" class="form-horizontal" role="form">
					<input type="hidden" name="url" id="url">
					<input type="hidden" name="mold" value="1">
					<div class="form-group">
						<label class="col-sm-2 control-label required">标题</label>
						<div class="col-sm-4">
							<input type="text" name="name" placeholder="50字以内,如:建筑设计"
								class="form-control" data-toggle="tooltip" data-placement="top"
								title="请输入不多于50个字">
						</div>
						<label class="col-sm-2 control-label required">论文格式</label>
						<div class="col-sm-4">
							<select class="form-control" name="type" placeholder="选择格式"
								data-toggle="tooltip" data-placement="top" title="请选择格式">
								<option value="0" selected="selected">请选择...</option>
							</select>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label required">一级分类</label>
						<div class='col-md-2'>
							<select class="form-control" name="top" placeholder="选择一级分类"
								data-toggle="tooltip" data-placement="top" title="请选择一级分类">
								<option value="0" selected="selected">请选择...</option>
							</select>
						</div>
						<label class="col-md-2 control-label required ">二级分类</label>
						<div class='col-md-2'>
							<select class="form-control" name="second" placeholder="选择二级分类"
								data-toggle="tooltip" data-placement="top" title="请选择二级分类">
								<option value="0" selected="selected">请选择...</option>
							</select>
						</div>
						<label class="col-md-2 control-label required">三级分类</label>
						<div class='col-md-2'>
							<select class="form-control" name="detail"  placeholder="选择三级分类" data-toggle="tooltip" data-placement="top"title="请选择三级分类">
								<option value="0" selected="selected">请选择三级分类...</option>
							</select>
						</div>
					</div>

				  	  <div class="form-group">
						<label class="col-sm-2 control-label required" >价格</label>
						  <div class="col-sm-4">
							 <input type="text" name="price" placeholder="请输入价格,如11.2" class="form-control" data-toggle="tooltip" data-placement="top" title="请输入价格">
						  </div>
						  
						  <label class="col-sm-2 control-label required">浏览的基数</label>
						  	<div class="col-sm-4">
								<input type="text" name="cardinal" placeholder="请输入浏览基数" class="form-control" data-toggle="tooltip" data-placement="top" title="请输入浏览基数"> 
							</div>
					  </div>
					  
				  	  <div class="form-group">
						<label class="col-sm-2 control-label required" >规划体系</label>
						  <div class="col-sm-4">
							      	<select class="form-control" name="hierId" placeholder="选择规划体系"
										data-toggle="tooltip" data-placement="top" title="请选择规划体系">
										<option value="0" selected="selected">请选择规划体系...</option>
									</select>
						  </div>
						  
						  <label class="col-sm-2 control-label required">等级</label>
						  	<div class="col-sm-4">
							      	<select class="form-control" name="grade" placeholder="选择等级"
										data-toggle="tooltip" data-placement="top" title="请选择等级">
										<option value="1" selected="selected">入门</option>
										<option value="2" >进阶</option>
									</select>								
							</div>
					  </div>	

					<div class="form-group">
						<label class="col-sm-2 control-label required">标签</label>
						<div class="col-sm-10">
							<input id="tags" type="text" class="tags" value="" />
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label required">简介</label>
						<div class="col-sm-10">
							<%=htmlData%>
							<!-- <form name="example" method="post" action="file_list.jsp"> -->
								<textarea id ="introduction" name="content1" cols="100" rows="8" style="width:100%;height:400px;"></textarea>
							<br />
							<!--<input type="submit" name="button" value="提交内容" /> (提交快捷键: Ctrl + Enter)
							 </form>	 -->
						</div>
					</div>
					
				</form>
			</div>
			<div class="modal-footer">
				<button id="btn_confirm_edit" type="button" class="btn btn-primary">确定</button>
			</div>
		</div>
	</div>
</body>
</html>

<%!private String htmlspecialchars(String str) {
		str = str.replaceAll("&", "&amp;");
		str = str.replaceAll("<", "&lt;");
		str = str.replaceAll(">", "&gt;");
		str = str.replaceAll("\"", "&quot;");
		return str;
	}%>